package com.apes.fico.finance.model.gl;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @ClassName GLVoucherPool
 * @Description 财务凭证池
 * @Author pengyb
 * @Date 2019/1/11 14:08
 * @Version 1.0
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = GLVoucherPool.CONST_TABLE_NAME, indexes = {
        @Index(columnList = "voucher_no,period,year,company_id,handwork_flag", unique = true)
})
public class GLVoucherPool extends BaseModel {
    public final static String CONST_TABLE_NAME = "gl_voucher_pool";
    @Id
    @Column(name = "id", nullable = false, length = 120)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "财务凭证池", padding = 8)
    @Comment("编码")
    private String id;

    @Column(name = "voucher_no")
    @Comment("凭证号")
    private int voucherNo = 1;

    @NotNull
    @Column
    @Comment("会计期间")
    private String period;

    @NotNull
    @Column
    @Comment("会计年度")
    private int year;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id", nullable = false)
    @Comment("公司")
    private PartyRole company;

    @NotNull
    @Column
    @Comment("凭证是否删除标注;0:启用状态,1:删除状态")
    private int cancel = 0;

    @Column(name = "handwork_flag", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("手工标记")  //0:机制凭证 1:手工凭证
    private boolean handworkFlag = true;


}
